package socket.udp;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Receive {
    public static void main(String[] args) throws Exception {
        int port = 8080;
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("F://3.txt")));
        DatagramSocket socket = new DatagramSocket(port);
        byte[] b = new byte[1024];
        DatagramPacket packet = new DatagramPacket(b, b.length);
        socket.receive(packet);
        bos.write(packet.getData());
        bos.flush();
    }
}
